/**
 * \file Token.h
 *
 * Asteriskos Compiler 1
 * Written 2010-2011, by Anthony Berlin and Alexander Carlqvist
 *
 * This file is part of ICC.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TOKEN_H
#define TOKEN_H

#include <GCB/Object.h>

#include "SourceLine.h"

/// Declarations of token ids. This must be found before we include "SymbolTable.h",
/// because the Symbol class uses TokenId.
#include "TokenId.h"

#include "SymbolTable.h"

#ifndef NULL_TOKEN
    #define NULL_TOKEN (Token*)NULL
#endif

class Token : public Object
{
public:
    /// Constructors for \c Token.
    Token(SourceLine* line, TokenId type, string lexeme);
    Token();

    /// Init some default values for data members.
    void init();

    /// Poke a character onto the lexeme.
    void poke(char character);

    /// Return a string-representation of the token type.
    string convert_type_to_string() const;

    /// Return a string-representation of the token.
    string to_string() const;

    /// This determines what type of token this is.
    TokenId m_type;

    /// A pointer to the line where this token was found.
    SourceLine* m_line;

    /// The lexeme that this token represents, if any.
    string m_lexeme;

    /// Flags describing the token.
    bool isLiteral;
    bool isPunctuator;
    bool isIdentifier;
    bool isKeyword;
    bool isSpecifier;
};

#endif // TOKEN_H
